{include file="pageheader_erp.htm"}

{insert_scripts files="../js/jquery.1.3.2.js"}

<!-- start warehouse list -->
 <div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th  width="5%">{$lang.erp_warehousing_style_id}</th>
	<th>{$lang.erp_warehousing_style}</th>
	<th width="10%">{$lang.erp_is_valid}</th>	
	<th width="10%">{$lang.erp_operation}</th>
  </tr>
  {foreach from=$warehousing_style key=key item=warehousing_style}
	<tr>
		<td align="center">{$warehousing_style.warehousing_style_id}</td>
		<td>{$warehousing_style.warehousing_style}</td>
		<td align="center"><span id="is_valid_{$warehousing_style.warehousing_style_id}" style="cursor:pointer;color:{if $warehousing_style.is_valid eq 1}red;{else}black;{/if}">{if $warehousing_style.is_valid}{$lang.erp_yes}{else}{$lang.erp_no}{/if}</span></td>
		<td align="center">
			{if $key neq 0}
			<a href="javascript:delete_it({$warehousing_style.warehousing_style_id})">{$lang.erp_operation_delete}</a>
			{/if}
		</td>
	</tr>
  {foreachelse}
  <tr><td class="no-records" colspan="5">{$lang.no_records}</td></tr>
  {/foreach}
</table>
</div>
<!-- end warehouse list -->

{literal}
<script language="JavaScript">
	
	function delete_it(warehousing_style_id)
	{
		function deleteWarehousingStyleResponse(res)
		{
			if(res.error==3)
			{
				alert(res.message);
				window.document.location.reload();
			}
			else if(res.error==0){
				window.document.location.reload();
			}
			else{
				alert(res.message);
			}
		}
	
		if(confirm('{$lang.erp_sure_to_delete}')){
			Ajax.call('erp_warehousing_style.php?act=delete_warehousing_style', 'warehousing_style_id=' + warehousing_style_id, deleteWarehousingStyleResponse, 'POST', 'JSON');
		}		
	}

   $(document).ready(function(){
   		
		//设置是否有效
   		$("span[id^='is_valid_']").click(function(){
			var $select_item=$(this);
			var warehousing_style_id=$select_item.attr('id');
			warehousing_style_id=warehousing_style_id.substr('is_valid_'.length,warehousing_style_id.length-'is_valid_'.length);
			
			function changeIsValidResponse(res)
			{
				if(res.error==0 && res.is_valid==1)
				{
					$select_item.css('color','red');
					$select_item.text('{$lang.erp_yes}');
					//alert(res.message);
				}
				else if(res.error==0 && res.is_valid===0)
				{
					$select_item.css('color','black');
					$select_item.text('{$lang.erp_no}');
					//alert(res.message);
				}
				else{
					
					alert(res.message);
				}
			}
			
			Ajax.call('erp_warehousing_style.php?act=change_is_valid', 'warehousing_style_id=' + warehousing_style_id, changeIsValidResponse, 'POST', 'JSON');
		});
		
		
   });   
</script>
{/literal}
{include file="pagefooter.htm"}

